package org.sunshine.ueditor.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baidu.ueditor.ActionEnter;
import com.baidu.ueditor.util.UploadBasePathUtil;

@RestController
@RequestMapping("/ueditor")
public class UeditorController {
	
	@Autowired
	private Environment env;

	@RequestMapping("/config")
	public String config(HttpServletRequest request, HttpServletResponse response) throws JSONException {  
		String rootPath = request.getSession().getServletContext().getRealPath("/");  
		
		String basePath = UploadBasePathUtil.findUploadBasePath(env);
	
        return new ActionEnter(request, rootPath, basePath).exec();  
    }



}
